<?php
/*
 * 进云智能生成平台
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
 */
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
if($_RQ['op']=='main'){
	$return['account']=$_SESSION['account']=pdo_get('core_accounts',array('uniacid'=>$_SESSION['uniacid']));
	$return['account']['hdps']=json_decode($return['account']['hdps'],true);
	$return['account']['apps']=json_decode($return['account']['apps'],true);
	$return['account']['plugins']=json_decode($return['account']['plugins'],true);
	$return['account']['h5game']=json_decode($return['account']['h5game'],true);
	$return['account']['navs']=json_decode($return['account']['navs'],true);
	$return['account']['mobilenavs']=json_decode($return['account']['mobilenavs'],true);
	$return['account']['links']=json_decode($return['account']['links'],true);
	$art_num=intval($_RQ['art_num']);
	$fenlei_num=intval($_RQ['fenlei_num']);
	$store_num=intval($_RQ['store_num']);
	$pageid=intval($_RQ['pageid']);
	if($_RQ['id']){
		$id=intval($_RQ['id']);
	}else{
		$id=uni_setting('default_mobile_web');
	}
	if($pageid){
		$id=pdo_getcolumn('core_account_web_tpl',array('id'=>$pageid,'uniacid'=>$_SESSION['uniacid']),'web_id');
	}
	$item=pdo_get('core_mobile_web',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']),array('title','html','nopc','openlogin','pc_html','head_id','foot_id','menu_id','updatetime','is_narrow'));
	if(!$item){
		exi('指定的网站不存在！','error');
	}
	if($item['openlogin']){
		cfc('core')->checklogin();
	}
	$back=cfc('core')->get_back_newss(array('plugin'=>'core','action'=>'welcome','id'=>$id));
	$item=array_merge($back,$item);
	$return['diy_page_id']=$id;
	if($_SESSION['os']=='windows' && $item['pc_html'] && !$item['nopc']){
		if($item['head_id']){
			$item['head_html']=pdo_getcolumn('core_mobile_web',array('id'=>$item['head_id'],'uniacid'=>$_SESSION['uniacid']),'head_html');
		}
		if($item['foot_id']){
			$item['foot_html']=pdo_getcolumn('core_mobile_web',array('id'=>$item['foot_id'],'uniacid'=>$_SESSION['uniacid']),'foot_html');
		}
	}else{
		//获取站点模板下面的代码
		if($pageid){
			$tpls=pdo_get('core_account_web_tpl',array('id'=>$pageid,'uniacid'=>$_SESSION['uniacid']),array('html','updatetime','setting'));
		}else{
			$tpls=pdo_get('core_account_web_tpl',array('is_open'=>1,'web_id'=>$id,'uniacid'=>$_SESSION['uniacid']),array('html','updatetime','setting'));
		}
		if($tpls['html']){
			$item['html']=$tpls['html'];
			$item['updatetime']=$tpls['updatetime'];
		}
		if(!$item['html']){
			exi('指定的网页，没有设计内容！','error');
		}
		$setting=json_decode($tpls['setting'],true);
		$return['menus']=$setting['isfooter']==1?$setting['footer']:array();
		$item['fee']=intval($setting['fee']);
		$item['htmltitle']=$setting['top']['title'];
		$item['html']=$item['html'].'?v='.$item['updatetime'];
	}
	$return['item']=$item;
	$fields=array('id','title','keyword','createtime','readnum','likenum','status','desc','pic_url','yingxiao');
	$orderby=array();
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['num']){
		$psize = $_RQ['num'];
	}else{
		$psize = 10;
	}
	$total='';
	$return['domain']=DOMAIN_PRE;
	set_html('title',$return['item']['htmltitle']?:$item['title']);
	$return['extradata']=array();
	$return['sharedata']=array(
		'title'=>$item['title'],
		'desc'=>$item['description']?:$item['title'].'的描述',
		'link'=>custom_url('core/welcome//id='.$id.'&fromuser='.$_SESSION['uid'],true),
		'imgUrl'=>tomedia($item['picurl'])
	);
	$_SESSION['homeurl']=custom_url('core/welcome//id='.$id.'&fromuser='.$_SESSION['uid']);
	$return['province']=cfc('tools')->pcd();
	if(empty($item['pc_html']) || $item['nopc']){
		$os='mobile';
	}
	$fields=array('id','title','keyword','createtime','readnum','likenum','status','desc','pic_url','yingxiao','content');
	$orderby=array();
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['num']){
		$psize = $_RQ['num'];
	}else{
		$psize = 10;
	}
	$total='';
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if($return['account']['newsgroupid']){
		$params['fenlei']=$return['account']['newsgroupid'];
		$return['newsgroupid']=$return['account']['newsgroupid'];
	}
	$news=pdo_getslice('core_account_article',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($news){
		foreach($news as &$item){
			$item['content'] = strip_tags(str_replace('&nbsp;','',$item['content']));
			$item['desc'] = $item['desc'] ? $item['desc'] : cfc('tools')->substr($item['content'],0,36);
			$item['picurl'] = $item['pic_url'] ? $item['pic_url'] : '../core/resource/images/nopic.jpg';
			$item['createtime']=date('y/m/d H:i:s',$item['createtime']);
			$item['url']=custom_url('core/article.list/detail/id='.$item['id'],true);
		}
	}
	$return['news']=$news;
	//是否关注
	$return['isfollow']=pdo_getcolumn('core_fans',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'follow');
	exi($return,'','','','',$os);
}
if($_RQ['op']=='get'){
	$return['account']=$_SESSION['account']=pdo_get('core_accounts',array('uniacid'=>$_SESSION['uniacid']));
	$return['account']['hdps']=json_decode($return['account']['hdps'],true);
	$return['account']['apps']=json_decode($return['account']['apps'],true);
	$return['account']['plugins']=json_decode($return['account']['plugins'],true);
	$return['account']['h5game']=json_decode($return['account']['h5game'],true);
	$return['account']['navs']=json_decode($return['account']['navs'],true);
	$return['account']['mobilenavs']=json_decode($return['account']['mobilenavs'],true);
	$return['account']['links']=json_decode($return['account']['links'],true);
	$return['homeurl']=$_SESSION['homeurl'];
	$return['extradata']=array();
	exi($return);
}
if($_RQ['op']=='getkefuset'){
	$kefuset=uni_setting('kefuset');
	$return['kefuset']=$kefuset;
	exi($return);
}